<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            margin: 20px;
            float: left;
        }
    </style>
  </head>
  <body>
    <script>
      function getRandomcolor(option = true) {
        let color = "#";
        if (option) {
          let arr = [
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            "A",
            "B",
            "C",
            "D",
            "E",
            "f",
          ];
          for (let i = 0; i < 6; i++) {
            let index1 = Math.floor(Math.random() * (15 - 0 + 1)) + 0;
            color += arr[index1];
          }
          console.log(color);
          return color;
        } else {
          let red = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
          let green = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
          let blue = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
          return 'rgba(red,green,blue)'

          }
          }
      getRandomcolor('false');
    </script>
    <script>
      for (let i = 0; i < 5; i++) {
        document.write(
          `<div style=background-color:${getRandomcolor(true)}></div>`
        );
      }
      for (let i = 0; i < 5; i++) {
        document.write(
          `<div style=background-color:${getRandomcolor(false)}></div>`
        );
      }
    </script>
  </body>
</html>
